<template>
  <div v-if="Object.keys(shop).length !== 0" class="shop-info">
    <!-- 店铺名 -->
    <div class="shop-top">
      <img :src="shop.logo" alt="" />
      <span>{{ shop.name }}</span>
    </div>
    <!-- 店铺概况 -->
    <div class="shop-middle">
      <div class="shop-middle-left">
        <div class="shop-sells">
          <div class="shop-count">{{ shop.sells | sellsCountFilter }}</div>
          <div class="shop-text">总销量</div>
        </div>
        <div class="shop-goods">
          <div class="shop-baby">{{ shop.goodsCount }}</div>
          <div class="shop-text">全部宝贝</div>
        </div>
      </div>
      <div class="shop-middle-right">
        <table>
          <tr v-for="(item, index) in shop.score" :key="index">
            <td>{{ item.name }}</td>
            <td class="score" :class="{ 'score-better': item.isBetter }">
              {{ item.score }}
            </td>
            <td class="better" :class="{ 'better-more': item.isBetter }">
              <span>{{ item.isBetter ? '高' : '低' }}</span>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <!-- 店铺展示 -->
    <div class="shop-bottom">
      <div class="enter-shop">进店逛逛</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailShopInfo',
  props: {
    shop: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  filters: {
    sellsCountFilter(val) {
      if (val < 10000) return val
      return (val / 10000).toFixed(1) + '万'
    }
  }
}
</script>

<style type="text/css" scoped>
.shop-info {
  padding: 25px 8px;
  border-bottom: 5px solid #f2f5f8;
}
.shop-top {
  display: flex;
  align-items: center;
  height: 15vw;
}
.shop-top img {
  width: 50px;
  height: 50px;
  margin: 0 15px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}
.shop-middle {
  display: flex;
}
.shop-middle-left {
  display: flex;
  align-self: center;
  text-align: center;
  padding: 20px;
}
.shop-sells {
  padding: 6px 0;
}
.shop-goods {
  padding: 6px 0;
  margin-left: 35px;
  border-right: 1px solid #ccc;
  padding-right: 25px;
}
.shop-text {
  margin-top: 8px;
  font-size: 12px;
}
.shop-count,
.shop-baby {
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.shop-middle-right table {
  width: 130px;
  margin-left: 10px;
  font-size: 13px;
}

.shop-middle-right table td {
  padding: 5px 0;
}
.score span {
  color: #5ea732;
}
.score-better span {
  color: #f13e3a;
}
.better span {
  background-color: #5ea732;
  color: #fff;
  text-align: center;
}
.better-more span {
  background: #f13e3a;
}
.shop-bottom {
  margin-top: 10px;
  text-align: center;
}
.enter-shop {
  display: inline-block;
  font-size: 14px;
  background-color: #f2f5f8;
  width: 150px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  border-radius: 10px;
}
</style>
